package cate.game.event.pay;

import cate.common.table.pay.PayItemRow;
import cate.game.role.system.RoleSystem;
import cp.solution.business.pay.PayRecordEntity;
import cate.game.event.GameEventListener;
import cate.game.role.Role;

public class AfterPayListener implements GameEventListener<AfterPayEvent> {
    @Override
    public void onEvent(AfterPayEvent gameEvent) {
        Role role = gameEvent.role;
        if (role != null) {
            PayRecordEntity record = gameEvent.record;
            try {
                long vipPoints = gameEvent.vipPoints;
                long payCents = record.payCents;
                PayItemRow pir = role.getGame().table.pay.item.get(record.itemTid);
                // 玩家历史记录
                role.getHistory().action.payNum((payCents / 100));
                role.getHistory().action.payTimes();
                // 增加vip积分
                role.getBase().addVipPoint(vipPoints);
                // 活动充值监听
                role.getActivity().onRecharge(payCents);
                // 超值首充 触发首充检测
                role.getActivity().superFirstPay.onPay();
                // 月卡
                role.getPay().tradeMall.monthCard.onPay(payCents);
                role.getSystem().update(RoleSystem.GmOper.TOTAL_PAY, payCents / 100);
                role.getSystem().update(RoleSystem.GmOper.TODAY_PAY, payCents / 100);
                role.getTrace().onPay(pir, payCents);
                role.getRes().watchAdvertisement.onPay(payCents);
            } finally {

            }
        }
    }
}
